#!/usr/bin/env python
# -*- coding: utf-8 -*-

__author__ = 'Tree Node'

'''
A WSGI application entry.
'''
import logging;

logging.basicConfig(level=logging.INFO)

import os, time

from datetime import datetime
from config import configs
from transwarp import db
import urls

def datetime_filter(t):
    delta = int(time.time() - t)
    if delta < 60:
        return u'1分钟前'
    if delta < 3600:
        return u'%s分钟前' % (delta // 60)
    if delta < 86400:
        return u'%s小时前' % (delta // 3600)
    if delta < 604800:
        return u'%s天前' % (delta // 86400)
    dt = datetime.fromtimestamp(t)
    return u'%s年%s月%s日' % (dt.year, dt.month, dt.day)

# init db:
db.create_engine(**configs.db)

if __name__ == '__main__':
    print 'Application is running...'
    urls.app.run(debug=True)
